OPT_RELEASE?=-O2
OPT_DEBUG?=-g -ggdb

CC=gcc
STD=-std=gnu99 -pedantic -fdiagnostics-color=always
WARN=-Wall -W
OPT=$(OPT_RELEASE)

ifeq ($(build_debug),1)
	OPT=${OPT_DEBUG}
endif

CFLAGS=-D_GNU_SOURCES -I../include
LDFLAGS=-L/usr/local/lib
LIBS=-lpthread -ljemalloc
AR=ar crus
RM=rm -f

#===================================================
.PHONY: test

OTHER_LIB_A = ../src/libez_c.a

test : test_c test_s

test_c : test_c.o
	${CC} ${LDFLAGS} ${LIBS} $< ${OTHER_LIB_A} ${OPT} -o $@

test_s: test_s.o
	${CC} ${LDFLAGS} ${LIBS} $< ${OTHER_LIB_A} ${OPT} -o $@

clean:
	${RM} test_s test_s.o test_c test_c.o

#===================================================
%.o: %.c
	${CC} ${STD} ${WARN} ${CFLAGS} ${OPT} -c $< -o $@

#===================================================
# DO NOT EDIT 
test_s.o: test_s.c
test_c.o: test_c.c
